package com.fone.player.billing.bean;

import java.io.IOException;
import java.io.InputStream;

import org.xmlpull.v1.XmlPullParser;

import android.util.Xml;

import com.fone.player.util.L;

public class WxParasBean extends PYBaseBean{
	
	private static String TAG = "WxParasBean";
	
	private String appId;
	public String getAppId() {
		return appId;
	}

	public void setAppId(String appId) {
		this.appId = appId;
	}

	public String getPartnerId() {
		return partnerId;
	}

	public void setPartnerId(String partnerId) {
		this.partnerId = partnerId;
	}

	public String getPrepayId() {
		return prepayId;
	}

	public void setPrepayId(String prepayId) {
		this.prepayId = prepayId;
	}

	public String getNonceStr() {
		return nonceStr;
	}

	public void setNonceStr(String nonceStr) {
		this.nonceStr = nonceStr;
	}

	public String getTimeStamp() {
		return timeStamp;
	}

	public void setTimeStamp(String timeStamp) {
		this.timeStamp = timeStamp;
	}

	public String getPackageValue() {
		return packageValue;
	}

	public void setPackageValue(String packageValue) {
		this.packageValue = packageValue;
	}

	public String getSign() {
		return sign;
	}

	public void setSign(String sign) {
		this.sign = sign;
	}

	private String partnerId;
	private String prepayId;
	private String nonceStr;
	private String timeStamp;
	private String packageValue;
	private String sign;
//	private PayReq req = null;
	private String state;
	private String ft;
	private String rurl;
	private String tof;


	public String getTof() {
		return tof;
	}

	public void setTof(String tof) {
		this.tof = tof;
	}

	public String getRurl() {
		return rurl;
	}

	public void setRurl(String rurl) {
		this.rurl = rurl;
	}

	public String getFt() {
		return ft;
	}

	public void setFt(String ft) {
		this.ft = ft;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}


	@Override
	public WxParasBean parseXml(InputStream is) {
		WxParasBean wxParasBean = null;
//		PayReq wxReq = null;
		
		if (is == null) {
			return wxParasBean;
		}
		try {
			XmlPullParser parser = Xml.newPullParser();
			parser.setInput(is, "utf-8");
			int evtType = parser.getEventType();
			while (evtType != XmlPullParser.END_DOCUMENT) {
				String tag = parser.getName();
				
				switch (evtType) {
				case XmlPullParser.START_TAG:
					if ("rst".equalsIgnoreCase(tag)) {
						wxParasBean = new WxParasBean();
//						wxReq = new PayReq();
					} else if (null != wxParasBean) {
						if("state".equalsIgnoreCase(tag)){
							wxParasBean.setState( parser.nextText());
						}else if("ft".equalsIgnoreCase(tag)){
							wxParasBean.setFt(parser.nextText());
						}else if ("appid".equalsIgnoreCase(tag)) {
							wxParasBean.setAppId(parser.nextText());
//							wxParasBean.appId = parser.nextText();
						}else if("partnerid".equalsIgnoreCase(tag)){
							wxParasBean.setPartnerId(parser.nextText());
//							wxParasBean.partnerId = parser.nextText();
						}else if("prepayid".equalsIgnoreCase(tag)){
							wxParasBean.setPrepayId(parser.nextText());
//							wxParasBean.prepayId = parser.nextText();
						}else if("noncestr".equalsIgnoreCase(tag)){
							wxParasBean.setNonceStr(parser.nextText());
//							wxParasBean.nonceStr = parser.nextText();
						}
						else if("timestamp".equalsIgnoreCase(tag)){
							wxParasBean.setTimeStamp(parser.nextText());
						}else if("packagevalue".equalsIgnoreCase(tag)){
							wxParasBean.setPackageValue(parser.nextText());
//							wxParasBean.packageValue = parser.nextText();
						}else if("sign".equalsIgnoreCase(tag)){	
							wxParasBean.setSign(parser.nextText());
//							wxParasBean.sign = parser.nextText();
						}else if("rurl".equalsIgnoreCase(tag)){	
							wxParasBean.setRurl(parser.nextText());
						} else if("tof".equalsIgnoreCase(tag)){	
							wxParasBean.setTof(parser.nextText());
						} else{
							parser.nextText();
						}
					}
					break;
				case XmlPullParser.END_TAG:
					break;
				}
				evtType = parser.next();
			}
		} catch (Exception e) {
			L.e(L.TAG, TAG, e.getMessage());
			wxParasBean = null;
		}finally{
			try {
				is.close();
			} catch (IOException e) {
				e.printStackTrace();
				L.e(L.TAG, TAG, e.getMessage());
			}
		}
		return wxParasBean;
	}


}
